package com.prs.crm.dao.ca.work.impl;

import java.io.Serializable;
import java.sql.SQLException;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.prs.crm.dao.ca.work.TookDepartmentDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.ca.work.ArticleInfo;
import com.prs.crm.domain.ca.work.TookDepartment;

public class TookDepartmentDaoImpl extends BaseDaoImpl<TookDepartment> implements TookDepartmentDao{

	@Override
	public TookDepartment getTookDepartmentById(Serializable id) {
		return this.getHibernateTemplate().get(TookDepartment.class, id);
	}

	@Override
	public void saveOrTookDepartment(TookDepartment tookDepartment) {
		this.getHibernateTemplate().saveOrUpdate(tookDepartment);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<TookDepartment> getAllDepartment() {
		return (List<TookDepartment>) this.getHibernateTemplate().execute(new HibernateCallback() {
			public Object doInHibernate(Session session)
					throws HibernateException, SQLException {
					Criteria criteria = session.createCriteria(TookDepartment.class);
					return criteria.list();
			}	
		});
	}

}
